Copyright: ®1994 Parachute Software


Help Contents
Contents

General Information

Properties

Events

VB Support Functions

New and Improved (1.5)


General Information

Overview

Properties and Events

Installation

Distribution

Support

Registering


Properties

ArrowDelay

BackColor

DataField

DateAtPoint

DateAtPointJul

DateDispStyle

DayAlignment

DOWAlign

DOWBackColor

DOWBorder

DOWDispStyle

DOWFontBold

DOWFontItalic

DOWFontName

DOWFontSize

DOWFontStrikeThru

DOWFontUnderline

DOWForeColor

EnableKeys

FirstDateShown

FirstDOW

FixedDayHeight

ForeColor

Julian

Language

LastDateShown

LineColor

MonAlign

MonBackColor

MonDispStyle

MonFontBold

MonFontItalic

MonFontName

MonFontSize

MonFontStrikeThru

MonFontUnderline

MonForeColor

OtherMonBackColor

OtherMonForeColor

PointX, PointY

PrintAction

PrintHeight,PrintWidth,PrintX,PrintY

PrintHDC

SelDayBackColor

SelDayForeColor

ShowAllDays

ShowArrows

ShowLines

ShowSelection

Text

TextFormat


Events

ClickDay

DblClickDay

DrawDay

DrawOnDay

MonthChange

QueryChangeDay

QueryChangeMonth

QueryChangeYear

YearChange


VB Support Functions

Overview

Constants

KalDrawBitmap

KalDrawDay

KalDrawText

KalMakeFont

KalWindowAPIRect


Examples


New and Improved (1.5)

New Features

Improved/Fixed


General Information - Overview
Overview

Kalendar is a custom control for displaying a calendar. The primary purpose of writing Kalendar was to provide a level of flexibility to VB programmers that was not available in most other calendar custom controls.

With Kalendar, you can:

•	Affect the way each day box is drawn.

•	Draw anything within each day box.

•	Print the calendar (with any custom drawing) either full page, or anywhere and any size on the page.

Check out the DrawDay and DrawOnDay events, and the PrintAction property to get a quick jump on these features.

Kalendar is also a bound control, supports drag and drop, and most of the standard events and properties. It can also be 'internationalized' by selecting a local language and date format.


Properties and Events

The following tables list all of the properties and events for Kalendar. The properties and events that are specific to Kalendar are highlighted.

Properties

(About)	ArrowDelay	BackColor
BorderStyle	DataField	DataSource
DateAtPoint	DateAtPointJul	DayAlignment
DOWAlign	DOWBackColor	DOWBorder
DOWDispStyle	DOWFontBold	DOWFontItalic
DOWFontName	DOWFontSize	DOWFontStrikeThru
FirstDateShown	DOWForeColor	DragIcon
DragMode	Enabled	EnableKeys
FirstDOW	FixedDayHeight	FontBold
FontItalic	FontName	FontSize
FontStrikethru	FontUnderline	ForeColor
Height	HelpContextID	Index
Julian	Language	LastDateShown
Left	LineColor	MonAlign
MonBackColor	MonDispStyle	MonFontBold
MonFontItalic	MonFontName	MonFontSize
MonFontStrikeThru	MonFontUnderline	MonForeColor
MousePointer	Name	OtherMonBackColor
OtherMonForeColor	PointX	PointY
PrintAction	PrintHDC	PrintHeight
PrintWidth	PrintX	PrintY
SelDayBackColor	SelDayForeColor	ShowAllDays
ShowArrows	ShowLines	ShowSelection
TabIndex	TabStop	Tag
Text	TextFormat	Top
Visible	Width
Events

ClickDay	DblClickDay	DragDrop
DragOver	DrawDay	DrawOnDay
GotFocus	KeyDown	KeyPress
KeyUp	LostFocus	MonthChange
MouseDown	MouseUp	MouseMove
QueryChangeDay	QueryChangeMonth	QueryChangeYear
YearChange


Installation

To install Kalendar, copy the following files to your \WINDOWS\SYSTEM directory.

•	KALENDAR.VBX

•	KALENDAR.HLP

•	KALENDAR.LIC	For registered users only.


Distribution

Kalendar.VBX is royalty free after registering it. You can distribute it with any application that you develop with it.However, you MAY NOT distribute the Kalendar.LIC file.

If you do not register the control, you will not be able to create .EXEs that use the Kalendar.VBX.

One license is required for each developer using Kalendar.VBX. Call for quantity discounts.


Support

Kalendar support is provided through the following channels:

Compuserve: CIS 73003,131

Mail: Parachute Software
324 Debbie Drive
Waukesha, WI 53186

Phone: (414) 524-1992

Priority is given to registered users of the product, but we will try to answer any questions you have during the evaluation of the product.


Registering

When you register Kalendar, you will receive the distributable version of the custom control, a user manual and free telephone support (toll-charges apply). Each copy of Kalendar.VBX is $35.00(U.S.).

You can order Kalendar on CompuServe. Just GO SWREG; the registration number is 3391.

To order Kalendar by mail, send check or money order to:

Parachute Software
324 Debbie Drive
Waukesha, WI 53186

Please specify diskette preference.


ArrowDelay

Usage

Kalendar.ArrowDelay [ = integerval ]

Description

Determines how fast the navigation arrows auto-repeat. Specify value in milliseconds. Default value is 500 (1/2 a second)

Data Type

Integer


BackColor

Usage

Kalendar.BackColor [ = colorval]

Description

Sets the background color of the day box.

Data Type

Color

Notes

This property can be set in the DrawDay event.


DataField

Usage

Kalendar.DataField [ = fieldname ]

Description

Used to specify/retrieve the data field that the control is bound to. Kalendar can only be bound to Date/Time fields. Binding to any other field type will cause an error to be generated.


DateAtPoint

Example

Usage

textvar = Kalendar.DateAtPoint

Read only.

Description

For some of the standard functions (MouseMove, MouseDown, DragOver, DragDrop), the coordinates of the mouse are returned. By using the PointX and PointY properties, you can determine what date (if any), the mouse is currently over. If the coordinates specified in PointX and PointY are not over a date, this property will return an empty string ("").

Data Type

String


DateAtPointJul

Example

Usage

longvar = Kalendar.DateAtPointJul

Read only.

Description

For some of the standard functions (MouseMove, MouseDown, DragOver, DragDrop), the coordinates of the mouse are returned. By using the PointX and PointY properties, you can determine what date (if any), the mouse is currently over. If the coordinates specified in PointX and PointY are not over a date, this property will return -1. This is a read-only property.

Data Type

Long

Notes

Use the DateAtPoint property to determine the validity of the date at a given point.


DateDispStyle

Usage

Kalendar.DateDispStyle [ = integerval ]

Description

Sets the manner in which the boxes around each day are displayed.

Valid Values

Value	Description
0	Normal - The days are drawn with the currently specified colors and fonts.
1	3-D - The days are drawn with highlights and shadows. The currently specified colors are used to draw the surface of the days.
2	User-Defined - For each day to be drawn, the DrawDay event is fired. See the DrawDay event for an example of this display style
Data Type

Integer


DayAlignment

Usage

Kalendar.DayAlignment [ = integerval ]

Description

Sets the manner in which the day numbers are displayed within each day box.

Data Type

Integer

Valid Values

Value	Description
0	Upper-left
1	Upper-center
2	Upper-right
3	Mid-left
4	Mid-center
5	Mid-right
6	Lower-left
7	Lower-center
8	Lower-right
Notes

This property can be set in the DrawDay event.


DOWAlign

Usage

Kalendar.DOWAlign [ = integerval ]

Description

Sets the alignment of the text in the day of the week title.

Data Type

Integer

Valid Values

Value	Description
0	Align left
1	Align right
2	Align center


DOWBackColor

Usage

Kalendar.DOWBackColor [ = colorval ]

Description

Sets the background color of the day of the week title.

Data Type

Color


DOWBorder

Usage

Kalendar.DOWBorder [ = integerval ]

Description

Sets whether or not a border is drawn around the text in the day of the week title.

Data Type

Integer (True | False)


DOWDispStyle

Usage

Kalendar.DOWDispStyle [ = integerval ]

Description

Sets the manner in which the day of the week title is shown.

Valid Values

Value	Description
0	None - No day of week is shown.
1	Long - The day of the week is completely spelled out.
2	Medium - The day of the week is displayed as the first three characters.
3	Short(1) - The day of the week is displayed as a single letter.
4	Short(2) - The day of the week is displayed as the first two characters.
Data Type

Integer


DOWFontBold

Usage

Kalendar.DOWFontBold [ = integerval ]

Description

This property is for setting the font in which to display the text in the day of the week title on the Kalendar.


DOWFontItalic

Usage

Kalendar.DOWFontItalic [ = integerval ]

Description

This property is for setting the font in which to display the text in the day of the week title on the Kalendar.


DOWFontName

Usage

Kalendar.DOWFontName [ = string ]

Description

This property is for setting the font in which to display the text in the day of the week title on the Kalendar.


DOWFontSize

Usage

Kalendar.DOWFontSize [ = numericval ]

Description

This property is for setting the font in which to display the text in the day of the week title on the Kalendar.


DOWFontStrikeThru

Usage

Kalendar.DOWFontStrikeThru [ = integerval ]

Description

This property is for setting the font in which to display the text in the day of the week title on the Kalendar.


DOWFontUnderline

Usage

Kalendar.DOWFontUnderline = [integerval]

Description

This property is for setting the font in which to display the text in the day of the week title on the Kalendar.


DOWForeColor

Usage

Kalendar.DOWForeColor [ = colorval ]

Description

Sets the foreground color of the day of the week title.

Data Type

Color


EnableKeys

Usage

Kalendar.EnableKeys [ = integerval ]

Description

Enables/disables the use of keys to navigate Kalendar. When this value is true, the left and right arrow keys move the date selection back and forth one day. The up and down arrows move the date selection back and forth one week.

Data Type

Integer (True | False)


FirstDateShown

Usage

[ integerval  = ] Kalendar.FirstDateShown

Description

Returns the the day that is shown first on the Kalendar. If ShowAllDays is False, then this property will return the first day of the month. Otherwise this will be the first day of the previous month that shows up on the Kalendar.

DataType

String


FirstDOW

Usage

Kalendar.FirstDOW [ = integerval ]

Description

Sets the day of the week which should be shown as the first day on the Kalendar. Valid values are 1 = Sunday, to 7 = Saturday.

Data Type

Integer


FixedDayHeight

Usage

Kalendar.FixedDayHeight [ = integerval ]

Description

This affects how the number of weeks for a particular month are drawn. Since all months will fit into 6 weeks, calendars are typically drawn with enough space reserved for those 6 weeks. For instance, June 1994 requires a total of five 7 day weeks to be displayed, whereas July 1994 needs six weeks.

Setting this property to True will cause Kalendar to dynamically size the height of each week, depending on how the month is laid out.

Data Type

Integer (True | False)


ForeColor

Usage

Kalendar.ForeColor [ = colorval]

Description

Sets the color of the text being drawn in the day box.

Data Type

Color

Notes

This property can be set in the DrawDay event.


Julian

Usage

Kalendar.Julian = [longval]

Description

Allows you to access the current Kalendar date as a Julian value. See the Text  property to get the date as a text string.

Data Type

Long


Language

Usage

Kalendar.Language = [integerval]

Description

Allows you to select a local language for displaying the month and day of week text.

Value	Description
0	English
1	French
2	Spanish
3	Italian
4	Portuguese
5	German
6	Dutch
7	Swedish
8	Danish
9	Norwegian
10	Polish
11	Finish
Data Type

Integer


LastDateShown

Usage

[ integerval  = ] Kalendar.LastDateShown

Read only

Description

Returns the the day that is shown last on the Kalendar. If ShowAllDays is False, then this property will return the last day of the month. Otherwise this will be the a day of the previous month that shows up on the Kalendar.

DataType

String


LineColor

Usage

Kalendar.LineColor = [colorval]

Description

Sets the color of the line that is drawn around each day box.

Data Type

Color

Notes

This value can be changed in the DrawDay event.


MonAlign

Usage

Kalendar.MonAlign [ = integerval ]

Description

Sets the manner in which the month title is aligned.

Valid Values

Value	Description
0	Align left.
1	Align right.
2	Align center.
Data Type

Integer


MonBackColor

Usage

Kalendar.MonBackColor[ = colorval]

Description

Sets the background color of the month title and any space not covered by a day box.

Data Type

Color


MonDispStyle

Usage

Kalendar.MonDisplayStyle [ = integerval ]

Description

Sets the manner in which the month title shown.

Valid Values

Value	Description
0	None - No title is shown.
1	Month - Just the month name is shown.
2	Month/Year - The month and the year are shown.
Data Type

Integer


MonFontBold

Usage

Use in the same manner as the standard fonts.

Description

This property is for setting the font in which to display the month title on the Kalendar.


MonFontItalic

Usage

Kalendar.MonFontItalic = [ integerval ]

Description

This property is for setting the font in which to display the month title on the Kalendar.


MonFontName

Usage

Kalendar.MonFontName = [ stringval ]

Description

This property is for setting the font in which to display the month title on the Kalendar.


MonFontSize

Usage

Kalendar.MonFontSize = [ numericval ]

Description

This property is for setting the font in which to display the month title on the Kalendar.


MonFontStrikeThru

Usage

Kalendar.MonFontStrikeThru = [ integerval ]

Description

This property is for setting the font in which to display the month title on the Kalendar.


MonFontUnderline

Usage

Kalendar.MonFontUnderline = [ integerval ]

Description

This property is for setting the font in which to display the month title on the Kalendar.


MonForeColor

Usage

Kalendar.MonForeColor[ = colorval]

Description

Sets the foreground color of the month title.

Data Type

Color


OtherMonBackColor

Usage

Kalendar.OtherMonBackColor[ = colorval]

Description

Sets the background color of a day box for a day that is not in the current month. This property only takes affect when the ShowAllDays property is True.

Data Type

Color

Notes

This property can be set in the DrawDay event.


OtherMonForeColor

Usage

Kalendar.OtherMonForeColor[ = colorval]

Description

Sets the foreground color of a day box that is not in the current month. This property only takes affect when the ShowAllDays property is True.

Data Type

Color

Notes

This property can be set in the DrawDay event.


PointX, PointY

Usage

Kalendar.PointX [ = twips]

Kalendar.PointY [ = twips]

Description

For some of the standard functions (MouseMove, MouseDown, DragOver, DragDrop), the coordinates of the mouse are returned. By using the PointX and PointY properties, you can determine what date (if any), the mouse is currently over. See the DateAtPoint property for an example of using these properties.

Data Type

Integer


PrintAction

Usage

Kalendar.PrintAction [ = integerval ]

Write only.

Description

This property allows  you to print a Kalendar on the currently selected printer. There are three ways you can print a Kalendar, Portrait, Landscape and User-Defined. The first two actions print the specified Kalendar full page, using the specified orientation. Using the user defined action allows you to print the Kalendar anywhere and any size on your page.

Data Type

Integer

Valid Values

Value	Description
1	Print full page, portrait orientation
2	Print full page, landscape orientation
3	Print the Kalendar using the PrintHeight, PrintWidth, PrintX and PrintY properties.


PrintHeight,PrintWidth,PrintX,PrintY

Example

Usage

Kalendar.PrintHeight [ = twips ]

Kalendar.PrintWidth [ = twips ]

Kalendar.PrintX [ = twips ]

Kalendar.PrintY [ = twips]

Write only.

Description

Use these properties to specify where on the page you want a Kalendar printed. Use the PrintHDC and PrintAction properties to actually print it. The Kalendar is printed on the current printer.

Data Type

Integer


PrintHDC

Example

Usage

Kalendar.PrintHDC [ = Printer.HDC ]

Write only.

Description

Use this property to indicate the HDC on which to print a Kalendar. Generally, you will set this property to the Printer object's HDC (Printer.HDC).

Data Type

Integer

Note

This property should always be set just before using the PrintAction property.


SelDayBackColor

Usage

Kalendar.SelDayBackColor[ = colorval]

Description

Sets the background color of the day box which is currently selected.

Data Type

Color

Notes

This property can be set in the DrawDay event.


SelDayForeColor

Usage

Kalendar.SelDayForeColor[ = colorval]

Description

Sets the color of the text in the day box which is currently selected.

Data Type

Color

Notes

This property can be set in the DrawDay event.


ShowAllDays

Usage

Kalendar.ShowAllDays[ = integerval]

Description

When this value is set to False, only the days within the current month are shown (i.e. 1 through 31). When this value is set to True, the first and last week that are drawn in a month are 'padded' with days from the previous and next months.

Data Type

Integer (True | False)


ShowArrows

Usage

Kalendar.ShowArrows[ = integerval]

Description

Sets whether or not the month navigation arrows are shown on the Kalendar. If the MonDispStyle is 0 (None), the arrows are not shown.

Data Type

Integer (True | False)


ShowLines

Usage

Kalendar.ShowLines[ = integerval]

Description

Indicates whether or not lines are drawn around each day box.

Data Type

Integer (True | False)


ShowSelection

Usage

Kalendar.ShowSelection[ = integerval]

Description

Indicates whether or not the currently selected day is shown in the SelDayBackColor and SelDayForeColor colors, or shown in the BackColor and ForeColor colors.

Data Type

Integer (True | False)


Text

Usage

Kalendar.Text[ = datetext]

Description

Sets the current date that the calendar is displaying. This property must be set with a string in the form that is indicated in the TextFormat property. An error is generated if the string is not a valid date string.

This is the property that is 'bound' to a data control. This means that the field that you are binding to should be in the correct format.

Data Type

Text


TextFormat

Usage

Kalendar.TextFormat [ = integerval]

Description

Sets or returns the format that the Text property will return its value in.

Value	Description
0	m/d/y
1	d/m/y
2	y/m/d
Data Type

Integer


ClickDay

Syntax

Sub ClickDay()

Description

This event is fired whenever the currently selected day changes, either by the user clicking on a day , the Text property being set or the Julian property being set. The current date is automatically updated when the user clicks on a date. This event will not be fired if the user clicks on a part of the calendar that is not a day (e.g. on the month); however, the standard Click event will be fired.


DblClickDay

Syntax

Sub DblClickDay()

Description

This event is fired whenever a user double clicks on a day. The current date is automatically updated when the user double clicks on a day. This event will not be fired if the user double-clicks on a part of the calendar that is not a day (e.g. on the month); however, the standard DblClick event will be fired.


DrawDay

Example 1	Example 2

Syntax

Sub DrawDay (hdc As Integer, State As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single, Cancel As Integer)

Parameters

hdc	The device context on which to draw. As a general rule, if you are going to draw your own date box, you will need to use Window's API calls. Most of these calls require and hdc in order to do their magic.
State	0 - Normal 1 - Selected, no focus 2 - Selected, have focus 3 - Other month day.
theDay	This is the date that needs to be drawn. Use the Visual Basic function Format to extract any necessary information. For example, to get the day to draw use Format(theDay, "d").
x, y, x2, y2	Describes the rectangle that makes up the day box. These values are in twips. If you use GDI calls, you will need to convert these to pixels.
Cancel	Set this value to true if you have drawn the day box. If you do not set this value to true, the day will be drawn using the calendars property settings.
Description

By responding to this event you can draw a day any way you want to. This event is fired only if the DateDisplay style is set to 2 (User).

There are two ways that you can respond to this event. The first way is the easiest and doesn't require any Windows API calls. When this event fires, you can change any of the properties that affect the display of a day box. For instance, you can change the BackColor property so that each day is drawn in a different color. The documentation indicates whether or not a property can be set during this event.

The Cancel should not be set to True if you draw the day box using this first method.

The second way to respond to this event is to draw the day box using Windows API calls and the hdc parameter. This is the most flexible way to draw your own Kalendar day box, providing you with the option of using any of the Windows GDI drawing calls. Refer to example 2 for one way of responding to this event.

When you use the second method of responding to this event, you must set the Cancel parameter to True, otherwise the VBX will draw over your drawing.

A third possible way to draw a day box is to ignore this event (thus letting the VBX draw each day box using the property settings) and respond to the DrawOnDay event.

Warning: Do not set break points in this function. If you need to debug the code in this event, try using Debug.Print statements.


DrawOnDay

Example

Syntax

Sub DrawOnDay (hdc As Integer, State As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single)

Parameters

hdc	The device context on which to draw. As a general rule, if you are going to draw your own date box, you will need to use Window's API calls. Most of these calls require and hdc in order to do their magic.
State	0 - Normal 1 - Selected, no focus 2 - Selected, have focus 3 - Other month day.
theDay	This is the date that needs to be drawn. Use the Visual Basic function Format to extract any necessary information. For example, to get the day to draw use Format(theDay, "d").
x, y, x2, y2	Describes the rectangle that makes up the day box. These values are in twips. If you use GDI calls, you will need to convert these to pixels.
Description

This event allows a you to draw information on a day box without having to draw it yourself (by responding to the DrawDay event). It is fired after the DrawDay event (when the DateDispStyle is User-Defined) and the DrawDay event does not set the Cancel parameter to True.

When this event fires, you can assume that the day box for theDay has been drawn (generally as a rectangle). You can then use Windows API calls with the hdc parameter to draw information on top of the day box.


MonthChange

Syntax

Sub MonthChange()

Description

This event is fired whenever the date of a Kalendar is changed to a new month.


QueryChangeDay

Example

Syntax

Sub Kalendar1_QueryChangeDay(theDay as Long, Cancel as Integer)

Description

This event is fired just before the ClickDay event. It allows  you to stop the change to a new date from the current date. The parameter, theDay is the day that Kalendar wants to change to. By setting the Cancel parameter to True, you will prevent Kalendar from changing to the date theDay. This is useful if you want to limit the range of days a user can choose (i.e. >= today or weekdays only)

Warning: Do not set break points in this function, it is not a pretty sight. If you need to debug the code in this event, try using Debug.Print statements.


QueryChangeMonth

Syntax

Sub Kalendar1_QueryChangeMonth(theDay as Long, Cancel as Integer)

Description

This event is fired just before the ClickDay event. It allows  you to stop the change to a new month from the current date. The parameter, theDay is the day that Kalendar wants to change to. By setting the Cancel parameter to True, you will prevent Kalendar from changing to the date theDay. This is useful if you want to limit the range of months a user can choose (i.e. >= this month)

Warning: Do not set break points in this function, it is not a pretty sight. If you need to debug the code in this event, try using Debug.Print statements.


QueryChangeYear

Syntax

Sub Kalendar1_QueryChangeYear(theDay as Long, Cancel as Integer)

Description

This event is fired just before the ClickDay event. It allows  you to stop the change to a new year from the current date. The parameter, theDay is the day that Kalendar wants to change to. By setting the Cancel parameter to True, you will prevent Kalendar from changing to the date theDay. This is useful if you want to limit the range of years a user can choose (i.e. >= this year)

Warning: Do not set break points in this function, it is not a pretty sight. If you need to debug the code in this event, try using Debug.Print statements.


YearChange

Syntax

Sub YearChange()

Description

This event is fired whenever the date of a Kalendar is changed to a new year.


VB Support Functions - Overview
Overview

Kalendar.Bas is a module provided with Kalendar that simplifies some of the Windows API functions for drawing.  It also contains constants for some of the properties for Kalendar.


Constants

Drawing states for Kalendar_DrawDay

KAL_STATE_NOT_SELECTED	Day not selected
KAL_STATE_SELECTED_WITH	Day selected, Kalendar has focus
KAL_STATE_SELECTED_WITHOUT	Day selected, Kalendar does not have focus
KAL_STATE_OTHERMONTH	Day is not from this month.
Kalendar printing options

KAL_PRINT_PORTRAIT	Print Kalendar full page in portrait mode.
KAL_PRINT_LANDSCAPE	Print Kalendar landscape full page
KAL_PRINT_USER	Print Kalendar as specified by user.
KalendarDrawBitmap bitmap alignments

KAL_DBM_UL	Draw bitmap in upper left of daybox.
KAL_DBM_UC	Draw bitmap in upper center of daybox.
KAL_DBM_UR	Draw bitmap in upper right of daybox.
KAL_DBM_CL	Draw bitmap in center left of daybox.
KAL_DBM_CC	Draw bitmap in center center of daybox.
KAL_DBM_CR	Draw bitmap in center right of daybox.
KAL_DBM_LL	Draw bitmap in lower left of daybox.
KAL_DBM_LC	Draw bitmap in lower center of daybox.
KAL_DBM_LR	Draw bitmap in lower right of daybox.


KalDrawBitmap

Syntax

Sub KalDrawBitmap (hDC As Integer, Pict As Control, x As Single, y As Single, x2 As Single, y2 As Single, Position As Integer, dwROp As Long)

Parameters

hdc	The device context to draw on (usually from DrawDay or DrawOnDay parameter)
Pict	The picture control that contains the bitmap the draw.
x, y, x2, y2	The size of the day box ( from DrawDay or DrawOnDay parameters)
Position	One of the KAL_DBM_ constants
dwROp	Bitwise operation to use to draw the bitmap. See the SRC constants in the Win31API.Txt file, provided with VB, for the various values.
Description

This subroutine draws a bitmap, that is stored in a picture box control, on a day box.


KalDrawDay

Syntax

Sub KalDrawDay (Kal As Control, hDC As Integer, STATE As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single)

Parameters

Kal	The Kalendar being drawn on
hDC	The hDC from the DrawDay or DrawOnDay call.
State	The State from the DrawDay or DrawOn Day call
theDay	theDay from the DrawDay or DrawOn Day call
x, y, x2, y2	The coordinate parameters form the DrawDay or DrawOnDay call
Description

This subroutine draws a complete day box. It can be used in a DrawDay event to draw a day box the same way that the custom control draws a day. It is not necessarily intended as a useful function, but provides examples of various Windows API calls.


KalDrawText

Syntax

Sub KalDrawText (hDC As Integer, theDay As Long, R As Rect, ByVal txt$, ctlFont As Control, MultiLine As Integer)

Parameters

hdc	The hdc from DrawDay or DrawOnDay call.
theDay	theDay from DrawDay or DrawOnDay call.
R	The rectangle in which the text will be drawn.
txt$	The string to be drawn
ctlFont	A control that is set up with the font and forecolor that the text is to be drawn in.
MultiLine	True to draw text with word-wrap.
Description

This subroutine simplifies the Windows API functions for drawing text on an hDC. It allows you to draw text within a rectangle, with optional word-wrap.


KalMakeFont

Syntax

Function KalMakeFont (hDC As Integer, Ctl As Control) As Integer

Parameters

hDC	hdc parameter from DrawDay or DrawOnDay
Ctl	The control that has the font information
Description

This subroutine simplifies the Windows API functions for creating a font object. When drawing custom text on a day box and you want to use a font other than the one selected for the Kalendar, you must create the desired font. Instead of having to understand all of the parameters for the CreateFont API function, simply use this function. All of the font information is used from the Ctl parameter.


KalWindowAPIRect

Syntax

Sub KalWindowAPIRect (x As Single, y As Single, x2 As Single, y2 As Single, rct As Rect)

Parameters

x, y, x2, y2	Twip coordinates to convert to rectangle.
rct	Rectangle structure to hold converted coordinates.
Description

You generally need to convert the twip coordinates returned by DrawDay and DrawOnDay to pixels when you are using the Windows API to draw information on a day box. This subroutine converts the twips into a pixel coordinate rectangle.


DateAtPoint Example

This code responds to a MouseMove event, by determining which date the mouse is currently over. It determines the date by setting PointX and PointY to the mouse's X and Y coordinates, then referencing the DateAtPoint property.

Sub Kalendar1_MouseMove (Button As Integer, Shift As Integer,
                         X As Single, Y As Single)
Dim tmpDay As String
Kalendar1.PointX = X
Kalendar1.PointY = Y
tmpDay = Kalendar1.DateAtPoint
If tmpDay <> "" Then
Kalendar1.Text = Kalendar1.DateAtPoint
End If
End Sub


DrawDay Example 1

This example shows how to respond to the DrawDay Event by changing the background color of a day, depending on what day of the week the day is. Weekdays are colored in bright purple and weekends are colored in dark purple.

Sub Kalendar1_DrawDay (hdc As Integer, STATE As Integer,
                       theDay As Long, x As Single,
                       y As Single, x2 As Single,

                       y2 As Single, Cancel As Integer)
Dim DOW As Integer
DOW = Format(theDay, "w")
Select Case STATE
        Case KAL_STATE_NOT_SELECTED:

            If DOW = 1 Or DOW = 7 Then

                Kalendar1.DayBackColor = RGB(128, 0, 128)

            Else

                Kalendar1.DayBackColor = RGB(255, 0, 255)

            End If

            Kalendar1.DayForeColor = RGB(0, DOW * 30, 0)

        Case KAL_STATE_SELECTED_WITH,

   KAL_STATE_SELECTED_WITHOUT:

            If DOW = 1 Or DOW = 7 Then

                Kalendar1.SelDayBackColor = RGB(255, 0, 0)

            Else

                Kalendar1.SelDayBackColor = RGB(192, 0, 0)

            End If

            Kalendar1.SelDayForeColor = RGB(0, DOW * 30, 0)

    End Select

    If DOW = 1 Or DOW = 7 Then

        Kalendar1.DayAlignment = 8

    Else

        Kalendar1.DayAlignment = 0

    End If

End Sub


DrawDay Example 2

This example shows how to respond to the DrawDay Event by drawing the entire day box using Windows API calls. Instead of drawing rectangles for the days, it draws ellipses.

Sub Kalendar1_DrawDay (hdc As Integer, STATE As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single, Cancel As Integer)

Dim retval As Integer

Dim oldPen As Integer

Dim txtDay As String

Dim r As Rect

Dim oldBrush

Dim oldColor, oldTextColor

Dim lx As Long

    txtDay = Format(theDay, "d")

    r.left = x / Screen.TwipsPerPixelX

    r.top = y / Screen.TwipsPerPixelY

    r.right = x2 / Screen.TwipsPerPixelX

    r.bottom = y2 / Screen.TwipsPerPixelY

    oldPen = SelectObject(hdc, GetStockObject(BLACK_PEN))

    Select Case STATE

        Case KAL_STATE_SELECTED_WITHOUT:

            oldBrush = SelectObject(hdc, GetStockObject(LTGRAY_BRUSH))

            oldColor = SetBkColor(hdc, RGB(192, 192, 192))

            oldTextColor = SetTextColor(hdc, 0)

        Case KAL_STATE_SELECTED_WITH:

            oldBrush = SelectObject(hdc, GetStockObject(LTGRAY_BRUSH))

            oldColor = SetBkColor(hdc, RGB(192, 192, 192))

            oldTextColor = SetTextColor(hdc, RGB(255, 0, 0))

        Case KAL_STATE_NOT_SELECTED:

            oldBrush = SelectObject(hdc, GetStockObject(WHITE_BRUSH))

            oldColor = SetBkColor(hdc, RGB(255, 255, 255))

            oldColor = SetTextColor(hdc, 0)

    End Select

    retval = Ellipse(hdc, r.left, r.top, r.right, r.bottom)

    retval = DrawText(hdc, txtDay, Len(txtDay), r, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE)

    retval = SelectObject(hdc, oldPen)

    retval = SelectObject(hdc, oldBrush)

    lx = SetBkColor(hdc, oldColor)

    lx = SetTextColor(hdc, oldTextColor)

    Cancel = True

End Sub


DrawOnDay Example

This code responds to a DrawOnDay event, by drawing one of seven bitmaps on the day to be drawn. To use this sample, copy this onto a form with a Kalendar on it, create an array of Picture controls with a different icon in each. Set the AutoRedraw property of the Picture controls to True.

Sub Kalendar1_DrawOnDay (hDC As Integer, STATE As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single)

Dim retval As Integer

Dim r As Rect

Dim w As Long, h As Long

    KalWindowAPIRect x, y, x2, y2, r

    InflateRect r, -1, -1

    r.top = r.bottom - Picture1(0).Height / Screen.TwipsPerPixelY

    r.left = r.right - Picture1(0).Width / Screen.TwipsPerPixelX

    w = Picture1(0).Width / Screen.TwipsPerPixelX

    If w > r.right - r.left Then

        w = r.right - r.left

    End If

    h = Picture1(0).Height / Screen.TwipsPerPixelY

    If h > r.bottom - r.top Then

        h = r.bottom - r.top

    End If

    retval = BitBlt(hDC, r.left, r.top, w, h, Picture1(theDay Mod 8).hDC, 0, 0, SRCAND)

End Sub


QueryChangeDay Example

This code responds to the QueryChangeDay event by not allowing any day previous to today to be selected.

Sub Kalendar2_QueryChangeDay (theDay As Long, Cancel As Integer)

    If theDay < Date Then

        Beep

        Cancel = True

    End If

End Sub


Print Kalendar Example

This code shows how to print a Kalendar using the PrintX, PrintY, PrintWidth, PrintHeight and PrintHDC properties. To use it, create a form with a Kalendar and a button on it. Copy the following code into the buttons Click event.

Dim saveMonFontSize As Single

Dim saveBackColor As Long

' Save the current state of the Kalendar.

    saveMonFontSize = Kalendar1.MonFontSize

    saveBackColor = Kalendar1.MonBackColor

' Set some properties so that it looks good.

    Kalendar1.MonFontSize = 14

    Kalendar1.MonFontBold = True

    Kalendar1.BorderStyle = 1

    Kalendar1.MonBackColor = RGB(255, 255, 255)

' Position the paper two inches down and two inches

' in, in a 3" X 3" square.

    Kalendar1.PrintX = 2880

    Kalendar1.PrintY = 2880

    Kalendar1.PrintWidth = 1440 * 3

    Kalendar1.PrintHeight = 1440 * 3

    Kalendar1.PrintHDC = Printer.hDC

    Printer.Print "This is a report with a Kalendar"

    Kalendar1.PrintAction = 3

    Kalendar1.MonFontBold = False

    Kalendar1.MonBackColor = saveBackColor

    Kalendar1.BorderStyle = 0

    Printer.EndDoc


New Features

International Support - Kalendar can now use dates in mdy, dmy and ymd formats. Also included are twelve foreign language month and day-of-week names.

New Properties and Events Help Optimize Your Code - Events are now generated when the month and year change, as well as when a day changes. By using these events and the new properties FirstDateShown and LastDateShown, you can pre-load data for faster display.

New QueryChange Events - Events are now generated before the Kalendar changes a month or a year, allowing you to keep a user in a specific month/year.

Speed Control - You can now control how fast the months change as the user presses and holds the navigation arrows down.

User Manual - Describes introductory and advanced techniques for using Kalendar.


Improved/Fixed

Navigation arrows stay down as long as the left mouse button is down.

Double-clicking on an OtherMon day now works.

On a month change, the selected day draws only once.

3D buttons now use the color properties for drawing.

Selected date does not reappear when ShowSelection is False.

Border not wiped out when BorderStyle is Fixed Single and ShowLines is False


Glossary of Terms

day box

day of the week title

month navigation arrows

month title


day box

The rectangle that makes up a single day on a Kalendar. This includes the bounding rectangle and the day number.


day of the week title

The portion of the Kalendar that shows the days of the week (i.e. Monday, Tuesday, etc.)


month navigation arrows

The arrows shown in the month title that allow a user to move to the next or previous month.


month title

The portion of the Kalendar that shows the name of the current month and year.


 The properties that you can change within this event are: DayAlignment, any color property for a day (e.g. ForeColor), and any font property for a day(e.g. FontName) .